﻿@{
    Layout = "~/Views/Shared/_IndexLayout.cshtml";
    ViewBag.Title = "数据库";
}
@using prince.CSSDemo.Models
@model List<Menu>

<script type="text/javascript">
    //增加标签 title：标签名 必须唯一  url：请求地址，会使用Ajax调用此地址，并将内容展现在标签中
    function addTab(title, url) {
        if ($('#tab').tabs('exists', title)) {
            $('#tab').tabs('select', title);
        }
        else {
            $('#tab').tabs('add', {
                title: title,
                closable: true,
                content: '<iframe scrolling="yes" frameborder="0"  src="' + url + '" style="width:100%;height:99%;"></iframe>'
            });
        }
    }

    $(document).ready(function () {
        //$("#leftMenu").accordion({
        //    animate: true
        //});
        //function tt() {
        //    $("#tab .tabs-wrap").width($("#tab").width());
        //}
    });
</script>

@helper AddButton(string title, string action)
{
    <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true, iconCls:'icon-mini-add'" style="width: 180px; text-align: left; margin: 3px;" onclick="addTab('@title', '@action');">@title</a>
}
<div data-options="region:'west', collapsible:true,title:'数据库操作'" id="leftMenu" class="easyui-accordion" style="width:25%; max-width:200px;">
    @foreach (var fun in Model.Where(p => p.ParentFun == 0))
    {
        <div title="@fun.FunName">
            @foreach (var subFun in Model.Where(p => p.ParentFun == fun.FunID))
            {
                @AddButton(subFun.FunName, subFun.FunURL);
            }
        </div>
    }
</div>

<!--主页面容器-->
<div class="easyui-tabs" data-options="region:'center',fit:'true'" id="tab">
</div>   